var express = require('express');
var qiniu = require('qiniu');
var router = express.Router();

const accessKey = 'yKhEDloMGIepFYy7kRU60jvi3EGt3SBcdiidowee';
const secretKey = 'y3H7E4PpqW1r1nxHh6kO_eiJWaeOAfr0X4BRNwXJ';
const mac = new qiniu.auth.digest.Mac(accessKey, secretKey);
var options = {
  scope: 'bookstore',
};
var putPolicy = new qiniu.rs.PutPolicy(options);

router.get('/getToken', function (req, res, next) {
  var uploadToken = putPolicy.uploadToken(mac);
  res.json({code: 200, msg: uploadToken});
});

module.exports = router;